package com.wds.controller;


import com.wds.domain.JsonResult;
import com.wds.domain.entity.Comment;
import com.wds.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论表(Comment)控制层
 *
 * @author wds
 * @since 2022-10-30 12:55:14
 */
@RestController
@CrossOrigin
@RequestMapping("/comment")
@Api(tags = "评论接口")
public class CommentController {

    // 服务对象
    @Autowired
    private CommentService commentService;

    @ApiOperation(value = "获取评论列表", notes = "获取一页的评论列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "articleId", value = "文章ID"),
            @ApiImplicitParam(name = "pageNum", value = "页码"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小")
    })
    @GetMapping("/commentList")
    public JsonResult<Object> getCommentList(Long articleId, Integer pageNum, Integer pageSize) {
        return commentService.getCommentList(articleId, pageNum, pageSize);
    }

    @GetMapping("/linkCommentList")
    public JsonResult<Object> getLinkCommentList(Long articleId, Integer pageNum, Integer pageSize) {
        return commentService.getLinkCommentList(articleId, pageNum, pageSize);
    }

    @PostMapping
    public JsonResult<Object> addComment(@RequestBody Comment comment) {
        return commentService.addComment(comment);
    }

}

